﻿<!DOCTYPE html>
<html lang="en">

	<head>
		<title>首件检验登记-精工云MES系统移动端</title>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
		<link href="/JG/Content/jquery/weui/style/weui.min.css" rel="stylesheet" />
		<link href="/JG/Content/jquery/jquery-weui/css/jquery-weui.min.css" rel="stylesheet" />
		<link rel="stylesheet" href="/JG/Content/css/bootstrap.min.css">
		<link href="/JG/Content/css/Global.css" rel="stylesheet" />
		<link href="/JG/Content/jquery/jquery-weui/css/icon.css" rel="stylesheet" />
		<link rel="stylesheet" href="/JG/Content/css/MobileFirstItemInspection.css?v=1">

		<script src="/JG/Content/jquery/jquery-3.2.1.min.js"></script>
		<script src="/JG/Content/LocalConfigs.js"></script>
		<script src="/JG/Content/LocalUserInfo.js"></script>
		<script src="/JG/Content/Utils.js?v=1"></script>

		<style type="text/css">
			/*.menuTree{*/
			/*margin-left:-30px;*/
			/*}*/
			/*.menuTree div{*/
			/*padding-left:30px;*/
			/*}*/
			/*.menuTree span:hover{*/
			/*background-color:#e6e6e6;*/
			/*color:#cf0404;*/
			/*}*/
			/*.menuTree a:hover{*/
			/*color:#06F;*/
			/*}*/
			/*.btn{*/
			/*height:30px;*/
			/*margin-top:10px;*/
			/*border-bottom:1px solid #CCC;*/
			/*}*/
		</style>
	</head>

	<body>
		<div id="ContentContainer">
			<header id="Header" class="header">
				<div class="empty">
					<span id="stations"></span>
				</div>
				<div class="weui-flex">
					<div class="weui-flex__item" style="position:absolute;">
						<span style="font-size:16px;padding-left: 10px;" class="icon icon-109 f-white" onclick="javascript:location.href='/JG/Quality/MobileFirstCheckout.html'">
                    返回
                </span>
					</div>
					<div class="weui-flex__item" style="text-align: center;">首件检验</div>
					<div class="weui-flex__item" style="position:absolute;right:10px;">
						<span @click="SaveBtn"><img src="/JG/Content/images/save.png" alt="" style="width:20px;"></span>
					</div>
				</div>
			</header>
			<!--解决浮动空内容div-->
			<div class="empty_div"></div>
			<!--主体部分-->
			<div id="MainPage" v-cloak>
				<div class="vessel" style="background-color: #FFFFFF">
					<div class="vessel_top">
						<ul class="list-group">
							<li class="list-group-item">
								<div>
									<span class="list-group-item-heading">生产线</span>
									<select class="form-control" v-model="FormData.NowProductionLineCode" v-on:change="ChooseProductionLine">
										<option v-for="(item,index) in ProLineData" v-bind:value="item.CXSJ_CXBM">{{item.CXSJ_CXMC}}</option>
									</select>
								</div>
							</li>
							<li class="list-group-item">
								<div>
									<span class="list-group-item-heading">送检人</span>
									<input v-model="FormData.InspectName" class="div_input div_input1" type="text" placeholder="请输入送检人姓名">
								</div>
							</li>
							<li class="list-group-item">
								<div>
									<span class="list-group-item-heading">检验人</span>
									<input v-model="LoginUser" readonly="readonly" class="div_span" type="text">
								</div>
							</li>
							<li class="list-group-item">
								<div>
									<span class="list-group-item-heading">任务单号</span>
									<input v-model="FormData.TaskCode" class="popup_input" type="text" readonly="readonly" id="TaskCode">
									<button type="button" class="choice" style="width:42px;line-height: 25px;font-size: 14px;color: #FFFFFF;background-color: #4BA250;border:none;border-radius: 2px">选择</button>
								</div>
							</li>
							<li class="list-group-item">
								<div>
									<span class="list-group-item-heading">订单号</span>
									<input v-model="FormData.OrderCode" disabled="value" class="div_span" type="text">
								</div>
							</li>
							<li class="list-group-item">
								<div>
									<span class="list-group-item-heading">产品编号</span>
									<input v-model="FormData.InvCode" readonly="readonly" class="div_span" type="text">
								</div>
							</li>
							<li class="list-group-item">
								<div>
									<span class="list-group-item-heading">产品名称</span>
									<input v-model="FormData.InvName" class="popup_input" type="text" readonly="readonly">
									<!--<button type="button" class="choice"-->
									<!--style="width:42px;line-height: 25px;font-size: 14px;color: #FFFFFF;background-color: #4BA250;border:none;border-radius: 2px">选择</button>-->
								</div>
							</li>
							<li class="list-group-item">
								<div>
									<span class="list-group-item-heading">检验方案</span>
									<select class="form-control select_val" v-on:change="CheckoutProjectClick(this)" v-model="FormData.MasterID">
										<option v-for="(item,index) in CheckoutProject" v-bind:value="item.JGMES_ZLGL_CPJYBZ_ID">{{item.CPJYBZ_BZMC}}</option>
									</select>
								</div>
							</li>
							<li class="list-group-item">
								<!--图片点击放大弹窗部分-->
								<div class="weui-gallery" id="gallery">
									<!--预览图片容器-->
									<div class="weui-gallery__img" id="galleryImg"></div>
									<!--图片删除按钮-->
									<div class="weui-gallery__opr">
										<a href="javascript:" class="weui-gallery__del" style="display: inline-block;width:100px;text-align: left">
											<i class="weui-icon-delete weui-icon_gallery-delete">删除</i>
										</a>
										<a href="javascript:" class="weui-back" id="weui-back" style="display: inline-block;width:100px;text-align: right">
											<span class="text-back" style="font-size: 1.3em;color:#FFFFFF">返回</span>
										</a>
									</div>
								</div>

								<!--上传图片按钮部分和显示图片部分-->
								<div class="weui-cells weui-cells_form">
									<div class="weui-cell">
										<div class="weui-cell__bd">
											<div class="weui-uploader">
												<div class="weui-uploader__hd">
													<p class="weui-uploader__title">图片上传(最多上传5张)</p>
												</div>
												<div class="weui-uploader__bd">
													<!--上传图片容器-->
													<ul class="weui-uploader__files" id="uploaderFiles"></ul>
													<!--上传图片按钮-->
													<!--<div class="weui-uploader__input-box">-->
													<!--<input id="uploaderInput" class="weui-uploader__input" type="file" accept="image/*" multiple=""-->
													<!--v-on:change="UploadingImg">-->
													<!--</div>-->
													<div class="weui-uploader__input-box" v-if="CurrImgNum<MaxImgNum">
														<input id="uploaderInput" class="weui-uploader__input" type="file" accept="image/*" multiple="" v-on:change="UploadingImg">
													</div>
												</div>
											</div>
										</div>
									</div>
								</div>
							</li>
							<li class="list-group-item">
								<div>
									<i v-on:click="GoCheckoutProject" style="width:10px;height:20px;display: inline-block;position: absolute;z-index:10;top:22.5px;right:7px;">
                                    <img src="/JG/Content/images/xiaojiantou.png" alt="" style="width:100%;">
                                </i>
								<span v-on:click="GoCheckoutProject" style="width:100%;height: 40px;line-height: 40px;display: inline-block;">检验项目明细</span>
									<!--<input type="text" placeholder="检验项目明细" style="position: relative;width:100%;line-height: 45px;border: none;outline-style: none">
								-->
								</div>
							</li>
							<li class="list-group-item">
								<div>
									<span>检验结果</span>
									<span class="choice_btn" style="margin-left: 89px;">
                                <input type="radio" name="judge" value="合格">合格
                                <input type="radio" name="judge" value="不合格">不合格
                            </span>
								</div>
							</li>
						</ul>
					</div>

					<!--保存按钮部分-->
					<!--<div class="save_btn">-->
					<!--<button type="button" style="background-color: #4EA057;" v-on:click="SaveBtn">保存</button>-->
					<!--</div>-->
				</div>

				<!--任务列表弹窗选项部分-->
				<div tabindex="-1" class="modal fade in" id="myModal" role="dialog" aria-hidden="true" aria-labelledby="myModalLabel">
					<div class="modal-dialog" style="width: 96%;">
						<div class="modal-content" style="background-color:#dae7f3;">
							<!--头部-->
							<div class="modal-header">
								<div>
									<button class="close" aria-hidden="true" type="button" data-dismiss="modal">×</button>
									<h4 class="modal-title" id="myModalLabel">生产任务列表</h4>
								</div>
								<!--搜索框部分-->
								<div class="task_btn row">
									<div class="search_list col-lg-12 col-md-12 col-sm-12" style="text-align: left">
										<div class="search_item">
											<span>单据信息</span>
											<input v-model="FormData.ProTaskCode" id="ProTaskCode" type="text" placeholder="订单号/任务单号">
										</div>
										<div class="search_item">
											<span>产品信息</span>
											<input v-model="FormData.KeyWord" id="KeyWord" type="text" placeholder="产品编号/产品名称/型号">
										</div>
										<div class="shut_btn">
											<button class="btn btn-success" v-on:click="SearchLine()">搜索</button>
											<button class="btn btn-success"  @click="SubData()">选择</button>
										</div>
									</div>
								</div>
							</div>
							<!--内容部分-->
							<div class="modal-body" id="tanchu" style="overflow-x: auto;overflow-y: auto;">
								<div class="info">
									<div class="list-group div_group" v-for="(item,index) in TaskCodeGat">
										
										
										<div class="list-group-item" >
											<label class="list-group-item-heading">订单号码</label>
											<span class="list-group-item-text"> {{item.OrderCode}}</span>
											<span class="list-group-item-text">
												 <div class="weui-cells weui-cells_checkbox" >
												  <label class="weui-cell weui-check__label" :for="item.TaskCode" style="width: 100px;">
													<div class="weui-cell__hd" style="text-align: center;" @click="onCheckBox(item)">
													  <input type="checkbox" class="weui-check" :name="item.TaskCode" :id="item.TaskCode" >
													  <i class="weui-icon-checked" style="margin-left: 45px;"  ></i>
													</div>
												  </label>
												</div>
											</span>
										</div>
										<div class="list-group-item">
											<label class="list-group-item-heading">任务单号</label>
											<span class="list-group-item-text"> {{item.TaskCode }}</span>
										</div>
										<div class="list-group-item">
											<label class="list-group-item-heading">产品编码</label>
											<span class="list-group-item-text"> {{item.InvCode }}</span>
										</div>
										<div class="list-group-item">
											<label class="list-group-item-heading">产品名称</label>
											<span class="list-group-item-text"> {{item.InvName }}</span>
										</div>
										<!--<div class="list-group-item">-->
										<!--<label class="list-group-item-heading">检验方案</label>-->
										<!--<span class="list-group-item-text">{{item.SCRW_CPGG }}</span>-->
										<!--</div>-->
										
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</body>

	<script src="/JG/Content/jquery/jquery-weui/js/jquery-weui.min.js"></script>
	<script src="/JG/Content/bootstrap.min.js"></script>
	<script src="/JG/Content/vue-v2.34.js"></script>
	<script src="/JG/Content/Common.js"></script>

	<script type="text/javascript">
		//body赋值滚动条
		window.onload = function() {
			var BodyWidth = $(window).width();
			var BodyHeight = $(window).height();
			//任务列表弹窗
			var ModalBodyHeight = BodyHeight - 165;
			$("#tanchu").height(ModalBodyHeight);
		}

		//上传图片部分的效果功能
		var SelImgIndex; //第几张图片
		$(function() {
			$gallery = $("#gallery"); //弹窗图片最外层div
			$galleryImg = $("#galleryImg"); //获取弹窗图片容器ID
			$uploaderInput = $("#uploaderInput"); //上传图片按钮
			$uploaderFiles = $("#uploaderFiles"); //上传的图片容器
			$gallery__del = $(".weui-gallery__del"); //获取弹窗图片删除按钮
			$galleryBack = $("#weui-back"); //获取弹窗图片返回按钮

			//点击图片放大效果
			$uploaderFiles.on("click", "li", function() {
				SelImgIndex = $(this).index(); //获取点击当前元素的下标
				$galleryImg.attr("style", this.getAttribute("style")); //getAttribute() 方法通过名称获取属性的值。获取当前点击元素的style属性让后改为display：block
				$gallery.fadeIn(100); //显示弹窗图片
			});

			//点击弹窗图片返回
			$galleryBack.on("click", function() {
				// $uploaderFiles.find("li");
				$gallery.fadeOut(100); //隐藏图片
			});
			// $gallery.on("click", function () {
			//     $uploaderFiles.find("li")
			//     $gallery.fadeOut(100);
			// });

			//删除图片效果
			$gallery__del.click(function() { //这部分刚才放错地方了，放到$(function(){})外面去了
				event.stopPropagation(); //制止冒泡事件
				$.confirm("确认要删除该图片吗？", "删除提示", function() {
					// $uploaderFiles.find("li").eq(SelImgIndex).remove();
					// $gallery.fadeOut(100);      //隐藏图片

					var li = $uploaderFiles.find("li").eq(SelImgIndex);
					if(vmPage.ImagePaths && vmPage.ImagePaths.length > 0) {
						vmPage.ImagePaths.splice(SelImgIndex, 1);
					}
					li.remove(); //删除一张移除一个li标签
					var num = $('.weui-uploader__file').length;
					vmPage.CurrImgNum = num;
					$gallery.fadeOut(100);

				});
			});
		});
	</script>
	<script type="text/javascript">
		var vmPage = new Vue({
			el: "#ContentContainer",
			data: {
				//ProductionLineCode:"",   //当前用户登陆产线对应的产线编码编码
				LoginUser: LocalUserInfo.GetUserInfo().UserName, //当前登陆用户
				curDate: "", //当前时间的产线
				ImagePaths: [], //上传图片文件集合
				CurrImgNum: "", //上传图片的数量,也就是li标签数量
				MaxImgNum: "5", //限制图片张数
				onCheckArray:[],
				FormData: {
					ProdLine: "", //产线名称
					InspectName: "", //送检人姓名
					ProductionDate: "", //计划日期
					OrderCode: "", //订单号,
					TaskCode: "", //任务单号
					InvCode: "", //产品编码
					InvName: "", //产品名称
					CheckoutType: "", //检验类型
					CheckoutTypeCode: "", //检验方案类型编码
					ProTaskCode: "", //用户输入的工单号/任务单号
					KeyWord: "", //用户输入的产品编号/产品名称/型号
					NowProductionLineCode: "", //当前用户选择的产线编码
					MasterID: "", //主表主键ID
					CheckoutClassifyName: "", //检验分类名称
					YesOrNotCheckout: "", //是否选中的合格或不合格
					//TextValue:"",       //检验值
					//DisQualification:"不合格",
					//Qualification:"合格",
					// ImgID: "",
					// StudentImg: ""
				},
				ProLineData: [], //产线集合
				TaskCodeGat: [], //任务单号信息集合
				CheckoutProject: [], //检验方案集合
				//InspectionList:[],      //检验项目表数据集合
				//YesOrNotCheckoutList:[],    //是否选中的合格或不合格集合
			},
			mounted: function() {
				var currSelf = this;
				currSelf.initData(); //初始化
				currSelf.ProdLineMethod(); //初始化
			},
			methods: {
				//初始化方法
				initData: function() {
					var currSelf = this;
					$.showLoading();
					$.ajax({
						type: "post",
						async: true, //异步
						url: LocalConfig.SrvPath + "/jgmes/jgmesBaseAction!getCxList.action",
						data: {},
						dataType: "json",
						success: function(result) {
							var retData = ReturnData(result);
							if(retData.IsSuccess) {
								if(retData.Data && retData.Data.length > 0) {
									currSelf.ProLineData = retData.Data;
									if(localStorage.getItem("jsonStr")) {
										currSelf.FormData.NowProductionLineCode = $.parseJSON(localStorage.getItem("jsonStr")).SJJY_CXBM; //把用户登陆时绑定的产线编码赋值
										currSelf.ProductScheme(localStorage.getItem("cpbm"));
										currSelf.FormData.OrderCode = $.parseJSON(localStorage.getItem("jsonStr")).DDH; //订单号,
										currSelf.FormData.InvCode = $.parseJSON(localStorage.getItem("jsonStr")).SJJY_CPBM; //产品编码
										currSelf.FormData.InvName = $.parseJSON(localStorage.getItem("jsonStr")).SJJY_CPMC; //产品名称


										//currSelf.FormData.CheckoutTypeCode = $.parseJSON(localStorage.getItem("jsonStr")).CPJYBZ_DJH;
										//$("input[name='judge'][value=" + $.parseJSON(localStorage.getItem("jsonStr")).SJJYZB_HG_CODE + "]").attr("checked", true);
									} else {
										currSelf.FormData.NowProductionLineCode = LocalUserInfo.GetUserInfo().ProductionLineCode; //把用户登陆时绑定的产线编码赋值
									}
									//初始化任务单信息
									if(currSelf.FormData.NowProductionLineCode) {
										//任务单号接口
										$.ajax({
											type: "post",
											async: true,
											url: LocalConfig.SrvPath + "/jgmes/commonAction!getScrw.action",
											data: {
												"userCode": LocalUserInfo.GetUserInfo().UserCode,
												"mac": LocalUserInfo.GetUserInfo().Mac,
												"cxCode": currSelf.FormData.NowProductionLineCode, //当前用户选择的产线
												"curDate": currSelf.curDate,
											},
											dataType: "json",
											success: function(result) {
												var ret = ReturnData(result);
												if(ret.IsSuccess) {
													if(ret.Data.length > 0) {
														currSelf.FormData.TaskCode = ret.Data[0].SCRW_RWDH; //任务单号
														currSelf.FormData.InvCode = ret.Data[0].SCRW_CPBH; //产品编码
														currSelf.FormData.OrderCode = ret.Data[0].SCRW_DDHM; //订单号
														currSelf.FormData.InvName = ret.Data[0].SCRW_NAME; //产品名称
														currSelf.FormData.WordCode = ret.Data[0].SCRW_GDHM //工单号

														//初始化检验方案信息
														if(currSelf.FormData.InvCode) {
															//根据产品获取检验方案列表接口
															$.ajax({
																type: "post",
																async: true,
																cache: true,
																url: LocalConfig.SrvPath + "/jgmes/jgmesFirstInspectionAction!getEffectiveProductStandard.action",
																data: {
																	"userCode": LocalUserInfo.GetUserInfo().UserCode,
																	"mac": LocalUserInfo.GetUserInfo().Mac,
																	//"cpbm": currSelf.FormData.InvCode, //产品编码
																	"jylx": "SJ", //检验类型(固定值)
																},
																dataType: "json",
																success: function(ret) {
																	var retData = ReturnData(ret);
																	if(retData.IsSuccess && retData.Data) {
																		currSelf.CheckoutProject = retData.Data;
																		currSelf.FormData.CheckoutTypeCode=retData.Data[0].CPJYBZ_JYLX_CODE;//JGMES_ZLGL_CPJYBZ_ID;JGMES_ZLGL_CPJYBZ_ID
																		currSelf.FormData.MasterID = retData.Data[0].JGMES_ZLGL_CPJYBZ_ID;//JGMES_ZLGL_CPJYBZ_ID;
																	} else if(!retData.Data) {
																		// var showMsg = "此任务单没有绑定相关的检验方案!";
																		// $.toptip(showMsg, "warning");
																	}
																	//保存已填写内容
																	if(localStorage.getItem("jsonStr")) {
																		currSelf.FormData.MasterID = $.parseJSON(localStorage.getItem("jsonStr")).JGMES_ZLGL_CPJYBZ_ID;
																		var imgs=$.parseJSON(localStorage.getItem("jsonStr")).SJJY_FJ;
																			if(typeof(imgs)=="string"){
																				imgs=$.parseJSON(imgs);
																			}
																			currSelf.ImagePaths =imgs;
																			var htmls="";
																			for(var i=0;i<imgs.length;i++){
																				imgpath=LocalConfig.SrvPath+imgs[i].path;
																				htmls+='<li class="weui-uploader__file" '
																				htmls+='	style="background-image: url('+imgpath+');" '
																				htmls+='	data-id="ZRClDvPrac0s2WWfkg2" data-url="'+imgpath+'">'
																				htmls+='	<div class="weui-uploader__file-content">0%</div>'
																				htmls+='	</li>'
																		}
																			$("#uploaderFiles").append(htmls);
																	}
																},
																error: function(xhr, status, errorThrown) {
																	console.error(errorThrown);
																}
															});
														}

													}
												} else if(!ret.Data) {
													var showMsg = "该生产产线没有任务信息!";
													// currSelf.SetOperateRecord(showMsg, false);
													$.toptip(showMsg, "warning");
												}

												//保存已填写内容
												if(localStorage.getItem("jsonStr")) {
													var jsonStr = $.parseJSON(localStorage.getItem("jsonStr"));
													//currSelf.FormData.ProdLine = 
													currSelf.FormData.TaskCode = jsonStr.SJJY_RWDH //任务单号
													currSelf.FormData.OrderCode = jsonStr.SJJY_DDH //订单号
													currSelf.FormData.InvCode = jsonStr.SJJY_CPBM //产品编码
													 
													currSelf.FormData.InvName =  jsonStr.SJJY_CPMC; //产品名称
													currSelf.FormData.MasterID = jsonStr.JGMES_ZLGL_CPJYBZ_ID//JGMES_ZLGL_SJJY_ID //检验标准主表 ID 
													currSelf.FormData.NowProductionLineCode = jsonStr.SJJY_CXBM //当前产线编码
													currSelf.FormData.YesOrNotCheckout = jsonStr.SJJYZB_HG_CODE //是否合格名称
													currSelf.FormData.InspectName = jsonStr.SJJY_SJR //送检人
													currSelf.LoginUser = jsonStr.SJJY_JYR //检验人
													$("input[name='judge'][value='" + jsonStr.SJJY_NO_CODE + "']").attr("checked", true);
												 	//currSelf.ImgData=JSON.parse(currSelf.DetailsData.ImgNameData);

//													currSelf.ImagePaths.push(jsonStr.SJJY_FJ[0]);
//													//currSelf.ImagePaths=   //检验照片
//													
//													var imgData = JSON.parse(jsonStr.SJJY_FJ[0]);
//													for(var i=0;i<jsonStr.SJJY_FJ.length;i++){
//														var imgData = jsonStr.SJJY_FJ[i];
//														currSelf.ImagePaths.push(jsonStr.SJJY_FJ[i]);
//														$($preview)[0].setAttribute('data-id', imgData.id); //setAttribute() 方法添加指定的属性，并为其赋指定的值。
//														$($preview)[0].setAttribute('data-url', imgData.path);
//														$preview.removeClass('weui-uploader__file_status');
//														currSelf.ImagePaths.push(imgData);
//													}
												}

											},
											error: function(xhr, status, errorThrown) {
												console.error(errorThrown);
											}
										});
									}
								}
							} else if(!retData.Data) {
								var showMsg = "未能找到产线信息";
								$.toptip(showMsg, "warning");
							}
						},
						error: function(xhr, status, errorThrow) {
							// console.error(status);
							$.toptip(status, "warning");
						},
						complete: function() {
							$.hideLoading();
						},
					});
				},
				
				//选中主表数据
				onCheckBox: function(vars){
					var currSelf = this;
					console.log(currSelf.onCheckArray.length)
					var ob={};
					var istate=-1;
					
					for(var i=0;i<currSelf.onCheckArray.length;i++){
						if(currSelf.onCheckArray[i].TaskCode==vars.TaskCode){
							istate=i;
							 break; 
						}
					}
					if(istate==-1){
						ob.TaskCode = vars.TaskCode;
						ob.OrderCode = vars.OrderCode;
						ob.InvCode = vars.InvCode;
						ob.InvName = vars.InvName;
						var taskId=vars.TaskCode;
						currSelf.onCheckArray.push(ob)
					}else{
						currSelf.onCheckArray.splice(istate,1)
					}
				},
				//选择切换当前产线方法
				ChooseProductionLine: function() {
					var currSelf = this;
					$.each(currSelf.ProLineData, function(index, item) {
						if(currSelf.FormData.NowProductionLineCode == item.CXSJ_CXBM) {
							currSelf.FormData.NowProductionLineCode = item.CXSJ_CXBM; //当前产线编码
							currSelf.FormData.ProdLine = item.CXSJ_CXMC;
							localStorage.removeItem('jsonStr');
							localStorage.removeItem('jsonStrDetail');
							currSelf.SwitcherProductionLine();
						}
					});
				},

				//另外选择产线时,页面数据重新赋值方法
				SwitcherProductionLine: function() {
					var currSelf = this;
					currSelf.FormData.InspectName = ""; //清空送检人
					currSelf.TaskCodeGat = []; //清空上一次产线任务单信息
					currSelf.CheckoutProject = []; //清空之前请求的检验方案集合
					currSelf.FormData.MasterID = ""; //清空之前选产线绑定的检验方案所对应的ID

					//初始化任务单信息
					if(currSelf.FormData.NowProductionLineCode) {
						//任务单号接口
						// $.showLoading();
						$.ajax({
							type: "post",
							async: true,
							url: LocalConfig.SrvPath + "/jgmes/commonAction!getScrw.action",
							data: {
								"userCode": LocalUserInfo.GetUserInfo().UserCode,
								"mac": LocalUserInfo.GetUserInfo().Mac,
								"cxCode": currSelf.FormData.NowProductionLineCode, //当前用户选择的产线
								"curDate": currSelf.curDate,
							},
							dataType: "json",
							success: function(result) {
								var ret = ReturnData(result);
								if(ret.IsSuccess) {
									if(ret.Data.length > 0) {
										currSelf.FormData.TaskCode = ret.Data[0].SCRW_RWDH; //任务单号
										currSelf.FormData.InvCode = ret.Data[0].SCRW_CPBH; //产品编码
										currSelf.FormData.OrderCode = ret.Data[0].SCRW_DDHM; //订单号
										currSelf.FormData.InvName = ret.Data[0].SCRW_NAME; //产品名称
										currSelf.FormData.WordCode = ret.Data[0].SCRW_GDHM //工单号

										// //初始化检验方案信息
										// if(currSelf.FormData.InvCode) {
										// 	//根据产品获取检验方案列表接口
										// 	// $.showLoading();
										// 	
										// }
										$.ajax({
											type: "post",
											async: true,
											cache: true,
											url: LocalConfig.SrvPath + "/jgmes/jgmesFirstInspectionAction!getEffectiveProductStandard.action",
											data: {
												"userCode": LocalUserInfo.GetUserInfo().UserCode,
												"mac": LocalUserInfo.GetUserInfo().Mac,
												//"cpbm": currSelf.FormData.InvCode, //产品编码
												"jylx": "SJ", //检验类型(固定值)
											},
											dataType: "json",
											success: function(ret) {
												var retData = ReturnData(ret);
												if(retData.IsSuccess && retData.Data) {
													currSelf.CheckoutProject = retData.Data;
													currSelf.FormData.CheckoutTypeCode=retData.Data[0].JGMES_ZLGL_SJJY_ID;
													currSelf.FormData.MasterID = retData.Data[0].JGMES_ZLGL_CPJYBZ_ID;
												} else if(!retData.Data) {
													// var showMsg = "此任务单没有绑定相关的检验方案!";
													// $.toptip(showMsg, "warning");
												}
											},
											error: function(xhr, status, errorThrown) {
												console.error(errorThrown);
											}
										});

									}
								} else if(!ret.Data) {
									var showMsg = "该生产产线没有任务信息!";
									// currSelf.SetOperateRecord(showMsg, false);
									$.toptip(showMsg, "warning");
								}
							},
							error: function(xhr, status, errorThrown) {
								console.error(errorThrown);
							}
						});
					}
				},
				//获取当前产线任务单全部信息方法
				ProdLineMethod: function() {
					var currSelf = this;
					$(".popup_input,.choice").click(function() {
						//清空原有加载数据
						currSelf.TaskCodeGat = [];
						//currSelf.j = "";   //清空之前选中当前下标的任务列表数据

						$("#myModal").modal("show");
						$.showLoading();
						//任务单号接口
						$.ajax({
							type: "post",
							async: true,
							url: LocalConfig.SrvPath + "/jgmes/commonAction!getScrw.action",
							data: {
								"userCode": LocalUserInfo.GetUserInfo().UserCode,
								"mac": LocalUserInfo.GetUserInfo().Mac,
								"cxCode": currSelf.FormData.NowProductionLineCode, //当前用户选择的产线
								"curDate": currSelf.curDate,
								// "zt": "RWZT01,RWZT02,RWZT04"
							},
							dataType: "json",
							success: function(result) {
								var ret = ReturnData(result);
								if(ret.IsSuccess) {
									if(ret.Data.length > 0) {
										for(var i in ret.Data) {
											var item = ret.Data[i];
											currSelf.TaskCodeGat.push({
												TaskCode: item.SCRW_RWDH, //任务单号
												InvCode: item.SCRW_CPBH, //产品编号
												OrderCode: item.SCRW_DDHM, //订单号
												InvName: item.SCRW_NAME, //产品名称
												WordCode: item.SCRW_GDHM, //工单号
												//BgsjCxbm: item.SCRW_CXBM,  //产线编码
											});
										}
									}
								} else if(!ret.Data) {
									var showMsg = "该生产产线没有任务信息!";
									// currSelf.SetOperateRecord(showMsg, false);
									$.toptip(showMsg, "warning");
								}
							},
							error: function(xhr, status, errorThrown) {
								// $.alert("任务单号请求失败!");
								$.toptip(status, "error");
							},
							complete: function() {
								$.hideLoading();
							}
						});
					});
				},

				//点击弹窗选择按钮方法
				SubData: function() {
					var currSelf = this;
					currSelf.CheckoutProject = []; //清空之前选择的检验方案
					currSelf.FormData.MasterID = ""; //清空绑定第一个检验方案的ID
					var val=currSelf.onCheckArray;
					$("#myModal").modal("hide");
					var TaskCode='';
					var OrderCode='';
					var InvCode='';
					var InvName='';
					for(var i=0;i<currSelf.onCheckArray.length;i++){
						if(currSelf.onCheckArray.length-1==i){
							TaskCode += val[i].TaskCode;
							OrderCode += val[i].OrderCode;
							InvName += val[i].InvName;
							InvCode += val[i].InvCode;
						}else{
							TaskCode += val[i].TaskCode+";";
							OrderCode += val[i].OrderCode+";";
							InvCode += val[i].InvCode+";";
							InvName += val[i].InvName+";";
						}
					}
					
					currSelf.FormData.TaskCode =  TaskCode;
					currSelf.FormData.OrderCode =  OrderCode;
					currSelf.FormData.InvCode =  InvCode;
					currSelf.FormData.InvName =  InvName;
					localStorage.setItem('cpbm',InvCode);
					$.showLoading();
					console.log(currSelf.FormData);
					currSelf.onCheckArray=[];
					//根据产品获取检验方案列表接口
					$.ajax({
						type: "post",
						async: true,
						cache: true,
						url: LocalConfig.SrvPath + "/jgmes/jgmesFirstInspectionAction!getEffectiveProductStandard.action",
						data: {
							"userCode": LocalUserInfo.GetUserInfo().UserCode,
							"mac": LocalUserInfo.GetUserInfo().Mac,
							//"cpbm": currSelf.FormData.InvCode, //产品编码
							"jylx": "SJ", //检验类型(固定值)
						},
						dataType: "json",
						success: function(ret) {
							var retData = ReturnData(ret);
//							console.log(retData);
							if(retData.IsSuccess && retData.Data) {
								currSelf.CheckoutProject = retData.Data;
								currSelf.FormData.MasterID = retData.Data[0].JGMES_ZLGL_CPJYBZ_ID;
							} else if(!retData.Data) {
								// var showMsg = "此任务单没有绑定相关的检验方案!";
								// $.toptip(showMsg, "warning");
							}
						},
						error: function(xhr, status, errorThrown) {
							// console.error(status);
							$.toptip(status, "error");
						},
						complete: function() {
							$.hideLoading();
						}
					});
				},
				ProductScheme:function(param){
					var currSelf = this;
					var cpbm=param;
					$.ajax({
						type: "post",
						async: true,
						cache: true,
						url: LocalConfig.SrvPath + "/jgmes/jgmesFirstInspectionAction!getEffectiveProductStandard.action",
						data: {
							"userCode": LocalUserInfo.GetUserInfo().UserCode,
							"mac": LocalUserInfo.GetUserInfo().Mac,
							"cpbm": cpbm, //产品编码
							"jylx": "SJ", //检验类型(固定值)
						},
						dataType: "json",
						success: function(ret) {
							var retData = ReturnData(ret);
//							console.log(retData);
							if(retData.IsSuccess && retData.Data) {
								currSelf.CheckoutProject = retData.Data;
								currSelf.FormData.MasterID = retData.Data[0].JGMES_ZLGL_CPJYBZ_ID;
							} else if(!retData.Data) {
								// var showMsg = "此任务单没有绑定相关的检验方案!";
								// $.toptip(showMsg, "warning");
							}
						},
						error: function(xhr, status, errorThrown) {
							// console.error(status);
							$.toptip(status, "error");
						},
						complete: function() {
							$.hideLoading();
						}
					});
				},

				//获取当前选中检验方案方法
				CheckoutProjectClick: function() {
					var currSelf = this;
					//currSelf.CheckoutClassifyData=[];
					$.each(currSelf.CheckoutProject, function(index, item) {
						if(currSelf.FormData.MasterID == item.JGMES_ZLGL_CPJYBZ_ID) {
							currSelf.FormData.CheckoutTypeCode = item.CPJYBZ_DJH; //检验类型编码
							currSelf.FormData.MasterID = item.JGMES_ZLGL_CPJYBZ_ID;
							localStorage.removeItem('jsonStr');
							localStorage.removeItem('jsonStrDetail');
						}
					});

				},

				//点击任务列表弹窗搜索按钮方法
				SearchLine: function() {
					var currSelf = this;

					if(!currSelf.FormData.NowProductionLineCode) {
						// bootbox.alert("请先输入需要搜索的内容!");
						$("#ProTaskCode").focus(); //点击搜索按钮时，搜索框获取聚焦
						$("#KeyWord").focus(); //点击搜索按钮时，搜索框获取聚焦
					} else {
						currSelf.TaskCodeGat = [];
						$.showLoading();
						//任务单号接口
						$.ajax({
							type: "post",
							async: true,
							url: LocalConfig.SrvPath + "/jgmes/commonAction!getScrw.action",
							data: {
								"userCode": LocalUserInfo.GetUserInfo().UserCode,
								"mac": LocalUserInfo.GetUserInfo().Mac,
								"cxCode": currSelf.FormData.NowProductionLineCode, //产线编码
								"curDate": currSelf.curDate, //当前产线的时间
								"noLike": currSelf.FormData.ProTaskCode, //获取当前用户输入任务单号
								"cpLike": currSelf.FormData.KeyWord, //获取当前用户输入产品关键字
							},
							dataType: "json",
							success: function(result) {
								var ret = ReturnData(result);
								//console.log(ret);
								if(ret.IsSuccess) {
									if(ret.Data.length > 0) {
										for(var i in ret.Data) {
											var item = ret.Data[i];
											currSelf.TaskCodeGat.push({
												TaskCode: item.SCRW_RWDH, //任务单号
												InvCode: item.SCRW_CPBH, //产品编号
												OrderCode: item.SCRW_DDHM, //订单号
												InvName: item.SCRW_NAME, //产品名称
												WordCode: item.SCRW_GDHM, //工单号
												//BgsjCxbm: item.SCRW_CXBM,  //产线编码
											});
										}
									}
								} else if(!ret.Data) {
									var showMsg = "搜索的该生产产线没有任务信息!";
									$.toptip(showMsg, "warning");
								}
							},
							error: function(xhr, status, errorThrown) {
								console.error(errorThrown);
								$.toptip("请求相关生产任务信息失败!", "error");
							},
							complete: function() {
								$.hideLoading();
							}
						});
					}
				},

				//图片上传功能方法
				UploadingImg: function(event) {
					var currSelf = this;
					//console.log(event);
					var ImgFormat = ['image/jpg', 'image/jpeg', 'image/png', 'image/gif']; //规定图片格式四种
					// 1024KB，也就是 1MB
					var maxSize = 1024 * 1024; //设置图片最大容量
					var maxWidth = 150; //图片最大宽度
					var files = event.target.files; //event对象中的target里面的files属性
					//console.log(files);

					// 如果没有选中文件，直接返回
					if(files.length === 0) {
						return;
					}

					if(currSelf.CurrImgNum + files.length > currSelf.MaxImgNum) {
						// $.toptip("最多只能上传"+ currSelf.MaxImgNum +"张图片","warning");
						$.toast("最多只能上传" + currSelf.MaxImgNum + "张图片", "forbidden");
						$("#uploaderInput").val();
						return;
						// $.alert('最多只能上传' + currSelf.MaxImgNum + '张图片');
					}

					//循环已上传的图片
					for(var i = 0; i < files.length; i++) {
						var file = files[i];
						//console.log(file);
						//FileReader主要用于将文件内容读入内存，通过一系列异步接口，可以在主线程中访问本地文件
						var reader = new FileReader();

						// 如果上传图片类型不在允许的类型范围内
						if(ImgFormat.indexOf(file.type) === -1) {
							$.toast('该类型不允许上传', "forbidden");
							continue;
						}

						//html5 使用readAsDataURL生成的base64编码的图片是2进制流，其优点是减少http的请求
						reader.readAsDataURL(file); //异步读取文件内容，结果用data:url的字符串形式表示

						//当读取操作成功完成时调用onload事件
						reader.onload = function(e) {
							var img = new Image(); //创建一个img对象，也就是img标签
							img.src = e.target.result; //获取当前上传

							//当图像装载完毕时调用的onload事件句柄。
							img.onload = function() {
								var w = Math.min(maxWidth, img.width); //Math.min返回给定数值中最小的数。如果任一参数不能转换为数值，则返回NaN
								var h = img.height * (w / img.width);

								//h5新特性，绘制图形
								var canvas = document.createElement('canvas');
								var ctx = canvas.getContext("2d");
								canvas.width = w;
								canvas.height = h;
								ctx.drawImage(img, 0, 0, w, h); //从指定位置裁剪原始图片指定宽高，填充到画布上：

								var $preview = $('<li class="weui-uploader__file weui-uploader__file_status" style="background-image:url(' + img.src + ')"><div class="weui-uploader__file-content">0%</div></li>');
								$('#uploaderFiles').append($preview); //在指定元素中尾部插入内容

								var num = $('.weui-uploader__file').length; //获取li个数
								currSelf.CurrImgNum = num;

								//图片上传接口
								var formData = new FormData();
								formData.append("filetype", file.type);
								formData.append("filename", file.name);
								formData.append("files", file);
								$.ajax({
									url: LocalConfig.SrvPath + "/jgmes/jgmesScrwAction!doFileUplod.action",
									type: "post",
									data: formData,
									contentType: false,
									processData: false,
									success: function(result) {
										var data = JSON.parse(result);
										//console.log(data);
										if(data.IsSuccess) {
											var imgData = JSON.parse(data.Data);
											// console.log(imgData);
											$($preview)[0].setAttribute('data-id', imgData.id); //setAttribute() 方法添加指定的属性，并为其赋指定的值。
											$($preview)[0].setAttribute('data-url', imgData.path);
											$preview.removeClass('weui-uploader__file_status');
											currSelf.ImagePaths.push(imgData);
											$.toast("上传成功", function() {
												//console.log('close');
											});
											//$(".weui-uploader__input-box").hide();
										}
									},
									error: function(xhr, type) {
										alert('Ajax error!')
									}
								});
							}
						}

						//FileReader.onprogress在读取数据过程中周期性调用
						reader.onprogress = function(e) {
							var percentComplete = ((e.loaded / e.total) || 0) * 100;
							//console.log(percentComplete);
						}
					}
					$("#uploaderInput").val("");
				},

				//链接跳转到检验项目页面方法
				GoCheckoutProject: function() {
					var currSelf = this;
					if(!currSelf.FormData.MasterID || currSelf.FormData.MasterID == null) {
						$.toptip("请先选择检验方案", "warning")
					} else {
						//保存主表信息到本地变量
						currSelf.FormData.YesOrNotCheckout = $(".choice_btn").find("input[type=radio]:checked").val(); //是否合格名称
						if(!currSelf.FormData.YesOrNotCheckout) {
							currSelf.FormData.YesOrNotCheckout = "";
						}
						var zjId=""
						if($.parseJSON(localStorage.getItem("jsonStr"))){
							zjId=$.parseJSON(localStorage.getItem("jsonStr")).JGMES_ZLGL_SJJY_ID
						}
						
						var jsonStr = JSON.stringify({		
							//"CPJYBZ_DJH":currSelf.FormData.CheckoutTypeCode,//
							"SJJY_RWDH": currSelf.FormData.TaskCode, //任务单号
							"SJJY_DDH": currSelf.FormData.OrderCode, //订单号
							"SJJY_CPBM": currSelf.FormData.InvCode, //产品编码
							"JGMES_ZLGL_SJJY_ID": zjId, //检验标准主表 ID
							"JGMES_ZLGL_CPJYBZ_ID":currSelf.FormData.MasterID,//检测方案ID
							"SJJY_CPMC": currSelf.FormData.InvName, //产品名称
							"SJJY_CXBM": currSelf.FormData.NowProductionLineCode, //当前产线编码
							"SJJY_NO_CODE": currSelf.FormData.YesOrNotCheckout, //是否合格名称
							"SJJY_SJR": currSelf.FormData.InspectName, //送检人
							"SJJY_JYR": currSelf.LoginUser, //检验人
							"SJJY_FJ":currSelf.ImagePaths,//检验照片
						});
						
						localStorage.setItem("jsonStr", jsonStr);
						
						
						window.location.href = "/JG/Quality/MobileCheckoutProject.html?MasterID=" + currSelf.FormData.MasterID;
					}
				},

				//保存按钮方法
				SaveBtn: function() {
					var currSelf = this;
					var msg;
					currSelf.InspectionList = []; //清空之前检验项目表数据
					currSelf.FormData.YesOrNotCheckout = ""; //清空之前选中的合格或不合格
					currSelf.FormData.YesOrNotCheckout = $(".choice_btn").find("input[type=radio]:checked").val(); //是否合格名称

					if(!currSelf.FormData.NowProductionLineCode || currSelf.FormData.NowProductionLineCode == null) {
						msg = '请先选择产线！';
						$.toptip(msg, "warning");
					} else if(!currSelf.FormData.InspectName || currSelf.FormData.InspectName == null) {
						msg = '还没填写送检人姓名!';
						$.toptip(msg, "warning");
					} else if(currSelf.LoginUser == null) {
						msg = '没有检验人姓名!';
						$.toptip(msg, "warning");
					}else if ($("#TaskCode").val() ==null||$("#TaskCode").val()==""||$("#TaskCode").val()==undefined){
						msg = '没有选择任务单!';
						$.toptip(msg, "warning");
					}
					// else if (!currSelf.TaskCodeGat || currSelf.TaskCodeGat.length) {
					//     msg = '请先选择任务单相关信息!';
					//     $.toptip(msg, "warning");
					// }
					else if(!currSelf.FormData.MasterID || currSelf.FormData.MasterID == null) {
						msg = '该产线下的任务单没有相关检验方案，请重新选择任务单信息!';
						$.toptip(msg, "warning");
					} else if(!currSelf.FormData.YesOrNotCheckout) {
						msg = '请先选择检验结果!';
						$.toptip(msg, "warning");
					} else {
						$.confirm("确定为" + currSelf.FormData.YesOrNotCheckout + "吗？", "操作提示", function() {
							
							var primarytab=$.parseJSON(localStorage.getItem("jsonStr"));
                        	
							//格式化子表数据
							var zbtable = $.parseJSON(localStorage.getItem("jsonStrDetail"));
							var jsonTab=new Array();
							for(var b in zbtable){
								for(var c in zbtable[b]){
									var ObjectJson={};
									if(zbtable[b][c].length>1){
										ObjectJson["JGMES_ZLGL_CPJYBZZB_ID"]=c;
										ObjectJson["JGMES_ZLGL_SJJYZB_ID"]=zbtable[b][c][0];
										ObjectJson["SJJYZB_JYFAZBZJID"]=c;
											if(zbtable[b][c][1]=="合格"){
												ObjectJson["SJJYZB_HG_CODE"]=1;
											}else if(zbtable[b][c][1]=="不合格"){
												ObjectJson["SJJYZB_HG_CODE"]=0;
											}
											if(zbtable[b][c].length>2){
												ObjectJson["SJJYZB_JYZ"]=zbtable[b][c][2];
											}
											if(zbtable[b][c].length>3){
												ObjectJson["SJJYZB_BZ"]=zbtable[b][c][3];
											}
											if(zbtable[b][c][1]!=""||zbtable[b][c][2]!=""||zbtable[b][c][3]!=""){
												jsonTab.push(ObjectJson);
											}
										//jsonTab.push(ObjectJson);
									}
								}
							}
							console.log("============"+currSelf.FormData.CheckoutTypeCode);
							var TaskCodes	=primarytab.SJJY_RWDH.split(";");
							var OrderCodes	=primarytab.SJJY_DDH.split(";");
							var InvCodes	=primarytab.SJJY_CPBM.split(";");
							var InvNames	=primarytab.SJJY_CPMC.split(";")

							var jsonStr = JSON.stringify({
								// "SJJY_RWDH": TaskCodes[i], //任务单号
								// "SJJY_DDH": OrderCodes[i], //订单号
								// "SJJY_CPBM": InvCodes[i], //产品编码
								// "SJJY_CPMC": InvNames[i], //产品名称
								"JGMES_ZLGL_CPJYBZ_ID":primarytab.JGMES_ZLGL_CPJYBZ_ID,//检测方案ID
								"JGMES_ZLGL_SJJY_ID": primarytab["JGMES_ZLGL_SJJY_ID"], //检验标准主表 ID
								"SJJY_CXBM": primarytab.SJJY_CXBM, //当前产线编码
								"SJJY_NO_CODE": primarytab.SJJY_NO_CODE=="合格"?1:0, //是否合格名称
								"SJJY_SJR": primarytab.SJJY_SJR, //送检人
								"SJJY_JYR": primarytab.SJJY_JYR, //检验人
								"SJJY_FJ": primarytab.SJJY_FJ,//检验照片
							});

							var jsonStrRwGl=[];
							for(var i=0;i<TaskCodes.length;i++){
								jsonStrRwGl.push({
									"RWDXXGLB_RWDH": TaskCodes[i], //任务单号
									"RWDXXGLB_DDH": OrderCodes[i], //订单号
									"RWDXXGLB_CPBM": InvCodes[i], //产品编码
									"RWDXXGLB_CPMC": InvNames[i], //产品名称
								});
							}
							$.ajax({
								type: "post",
								//async: false,
								url: LocalConfig.SrvPath + "/jgmes/jgmesFirstInspectionAction!doSaveFirstInspection.action",
								data: {
									"userCode": LocalUserInfo.GetUserInfo().UserCode,
									"mac": LocalUserInfo.GetUserInfo().Mac,
									"jsonStr":jsonStr ,       //主表
									"jsonStrDetail": JSON.stringify(jsonTab) ,  //子表
									"jsonStrRwGl":JSON.stringify(jsonStrRwGl),
								},
								dataType: "json",
								success: function (result) {
									var retData = ReturnData(result);
									if (retData.IsSuccess) {
										localStorage.removeItem('jsonStr');
										localStorage.removeItem('jsonStrDetail');
										msg = "保存成功!";
										$.toptip(msg, "success");
										window.location.href = "/JG/Quality/MobileFirstCheckout.html";
									} else {
										msg = "保存失败!";
										$.toptip(msg, "error");
									}
								},
								error: function (xhr, status, errorThrow) {
									console.error(status);
									$.hideLoading();
									//$.alert("批量保存数据失败！");
								},
								complete: function () {
									$.hideLoading();
								}
							});
						});
					}
				}
			},
		});
	</script>

</html>